/*
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-06-02 11:16:10
 * @LastEditTime: 2022-06-02 11:16:18
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description: 
 */
function getInstanceof(left, right) {
  //基本数据类型直接返回false
  if ((typeof left !== 'object' && typeof left !== 'function') || left === null) return false
  let proto = left.__proto__
  //等价于let proto=Object.getPrototypeOf(left)
  while (true) {
    //查找到尽头 还没找到
    if (proto === null) return false
    //找到相同的原型对象
    if (proto == right.prototype) {
      return true
    }
    proto = proto.__proto__
  }
}
const a = new Object()
console.log(getInstanceof(a, Object))